<div id="tabstrip">
    <ul>
        <li class="k-state-active">
            Danh sách giáo viên
        </li>
        <li>
            Upload danh sách giáo viên
        </li>
    </ul>
    
    <div style="height:620px;">
        <table class="tbl" border="1" style="table-layout:auto; width:820px;" id="tb">
            <thead> 
                <tr style="font-size:13px;"> <td>STT</td> <td>Họ tên</td> <td>Học vị</td> <td colspan="2">Lựa chọn</td> </tr>
            </thead>
            <tbody>
                <?php
                    $i = 1;	$display = 10; static $id_gv;
                    if( isset($_GET['page']) && (int)$_GET['page'] )
                        $page = $_GET['page'];
                    else
                    {
                        $query = mysql_query(" SELECT count(id) FROM teachers WHERE name != '' ");
                        $row = mysql_fetch_array($query,MYSQLI_NUM);
                        $total_row = $row['0'];
                        if($total_row > $display)
                            $page = ceil($total_row/$display);
                        else
                            $page = 1;
                    }
                    $start = ( isset($_GET['start']) && (int)$_GET['start'] >= 0 ) ? $_GET['start'] : 0;
                    $sql = mysql_query(" SELECT id,name,degree FROM teachers
                                            WHERE name != '' ORDER BY name LIMIT $start,$display ");
                    if(mysql_num_rows($sql) > 0)
                    {
                        while($row = mysql_fetch_array($sql))
                        {
                            $id = $row['id'];   $id_gv = $id;
                            $name = $row['name'];
                            $degree = $row['degree'];
                            echo "<tr>";
                                echo "<td>".$i."</td>";
                                echo "<td>".ucwords($name)."</td>";
                                echo "<td>".ucwords($degree)."</td>";
                                echo "<td> <a href='#' class='option' id='show-popup'> Sửa </a> </td>";
                                echo "<td> <a href='teacher/delete.php?id=$id' class='option' onClick=\"return confirm('Bạn có thực sự muốn xóa giáo viên {$name} ?')\"> Xóa </a> </td>";
                                $i++;
                            echo "</tr>";
                            
                            $query1 = mysql_query(" SELECT id,name,degree,subject FROM teachers WHERE id = {$id_gv} ");
                        }
                    }
                    else
                        echo "<tr> <td colspan='7'> Chưa có giáo viên </td> </tr>";
                ?>
            </tbody>
        </table>
		<table class="nav">
			<?php
				if($page > 1)
				{
					$prev = $start - $display ;
					$next = $start + $display;
					$current = ($start/$display) + 1;
					echo "<tr>";
					for($i=1 ; $i<=$page ; $i++)
					{
						if($current != $i)
							echo "<td><a href='index.php?p=lst_tea&start=".($display*($i-1))."&page=$page#tb' style='color:#fff;'>Trang $i</a></td>";
						else
							echo " <td class='current'> Trang $i </td> ";
					}
		
					echo "</tr>";
				}
			?>
		</table>

    </div>
    <div style="height:420px;">
        <form method="post" enctype="multipart/form-data" class="frm" style="width:800px; margin-top:50px;" action="teacher/_import.php">
        	<h1> Upload file excel danh sách giáo viên </h1>
            <p> Vui lòng chọn File excel cần upload <input name="files" id="files" type="file" /> </p>
            <p> (Chỉ hổ trợ file excel) </p>
            <p style="margin:20px 0px; text-align:center;"> <input type="submit" value="Submit" class="button" /> </p>
		</form>
		<p style="margin:70px 0px 0px 20px; font-size:18px;">
            <a href="../../include/excel/dsgv.php" target="_blank"> 
                Download mẫu File import thông tin giáo viên 
            </a>
        </p> 
    </div>
    
</div>

<!-- Show popup -->
<div id="popup-bg"></div>
<div id="popup">
	<div id="popup-header">CẬP NHẬT THÔNG TIN GIÁO VIÊN<span id="popup-close" title="Close">x</span></div>
    <div id="popup-content">
        <?php
            
            if(mysql_num_rows($query1) > 0)
            {
                $row1 = mysql_fetch_array($query1);
        ?>
        <form method="post" class="frm">
            <label>Họ tên giáo viên</label> <input type="text" name="name" id="name" value="<?php echo $row1['name']; ?>" />
            <label>Học vị</label> <input type="text" name="degree" id="degree" value="<?php echo $row1['degree']; ?>" />
            <label>Môn giảng dạy</label> <input type="text" name="subject" id="subject" value="<?php echo $row1['subject']; ?>" />
            <input type="submit" id="submit" name="submit" class="button" />
        </form>
        <?php } ?>
    </div>
</div>


